﻿using System;
using System.ComponentModel;
using System.Data;
using ReflectionStudio.Core.Events;
using System.Windows;
using System.Threading;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for EditEventWindow.xaml
    /// </summary>
    public partial class UIGAAUF : ViewBase
    {


        public UIGAAUF()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MESSAGES += "CHKGD;GDCHG;GDRELOAD;GDBS61;MUREV;";
        }

        public override void Window_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            base.Window_Loaded(sender, e);
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            dwGD = dwMaster;
            if (dwMaster == null)
            {

            }
            else
            {
                DATBIS = TMV.GADATBIS;

            }

        }
        public override void OnEXAUFChg(string vlaue)
        {
            if (!IsCanLoad)
                return; 
            TBMain.Clear();
            if (vlaue.Length < 11)
                return;
            dwData = TBMain.NewRow();
            dwData["GAMANDANT"] = app.Mandant;
            dwData["GAAUFKRS"] = vlaue.Substring(1, 2);
            dwData["GAAUFLFD"] = vlaue.Substring(3, 6);
            dwData["GAAUFPOS"] = vlaue.Substring(9, 3); 
            dwData["GASA"] = GASA; 
            SResult = TMV.QGD22(dwData);
            MergeData(SResult, false);
            base.OnEXAUFChg(vlaue);
        }
        public override void OnSave()
        {
            foreach (DataRow row in TBMain.Rows)
            {
                TMV.UpdateGAAUF(row, 0);
            }
            base.OnSave();
        }
        #region====WorkFlow========
        public override void OnWorkflowIDChange(MessageEventArgs e)
        {
            try
            {

                base.OnWorkflowIDChange(e);
                MessageInfo msg = e.Info;
                string task = msg.MSGTYPE;
                switch (task)
                {
                    case "CHKGD":
                    case "GDRELOAD":
                        CHKGD(msg);
                        break;
                    case "GDBS61":
                    case "GDBS6D":
                    case "GDCHG":
                        GDCHG(msg);
                        break;
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public void GDCHG(MessageInfo msg)
        {
            if (!msg.ORDER.EndsWith(POSTYP))
                return;
            TOLOCK = ((VGAAUF)MV).LOADGD(msg);
            vwMaster.View.MoveCurrentToFirst();
        }
        #endregion

        public void MUREV(MessageInfo msg)
        {
            if (!FTMUREV)
                return;
            DataSet Set = msg.Set;
            foreach (DataRow row in Set.Tables[0].Rows)
            {
                dwData = TBMain.NewRow();
                dwData["GAMANDANT"] = app.Mandant;
                dwData["GAAUFKRS"] = row["ABAVKAUFKRS"];
                dwData["GAAUFLFD"] = row["ABAVKAUFLFD"];
                dwData["GAAUFPOS"] = row["ABAVKAUFPOS"];
                dwData["GAPOS"] = Helpers.Helper.Right(row["ABAVKUPOS"].ToString(), 2);
                dwData["GAKG2"] = Convert.ToDouble(row["ABARESMG"].ToString()) * 0.1;
                ((VGAAUF)MV).UpdateGAAUF(dwData, 20);
            }
        }

        public MessageInfo LastMsg = null;
        /// <summary>
        /// 起到更新作用
        /// </summary>
        /// <param name="msg"></param>
        public virtual void CHKGD(MessageInfo msg)
        {

        }
        public void CHGGD(MessageInfo msg)
        {
            RUNID = msg.Sender;
            PM["RUNID"] = msg.Sender;
            PM["AUFTYP"] = msg.AUFTYP;
            PM["ART"] = msg.ART;
            PM["FARBE"] = msg.FARBE;
            PM["VAR"] = msg.VAR;
            PM["ORDERNUM"] = msg.ORDER;
            PM["DELDATE"] = msg.P1;
            PM["QTY"] = msg.QTY;
            PM["VKPZUSATZ"] = msg.P3;
            if (msg.AUFTYP == "K")
            {
                PM["ARTSTAGE"] = "S";
            }
            PM["VKPAUF"] = msg.ORDER;
            PM["VKAUF"] = msg.ORDER;
            PM["VKPQTY"] = msg.QTY;
            ((VGAAUF)MV).Update(dwGD, PM);
            LastMsg = null;
        }
        public override void NewCommand(object sender, System.Windows.RoutedEventArgs e)
        {
            base.NewCommand(sender, e);
        }

        public virtual void OrderCommand(object sender, RoutedEventArgs e)
        {

        }

        public override void LOADBYAUF()
        {
            base.LOADBYAUF();
            TBMain.Clear();
            if (ORDERNUM.Length < 11)
                return;
            dwData = TBMain.NewRow();
            dwData["GAMANDANT"] = app.Mandant;
            dwData["GAAUFKRS"] = ORDERNUM.Substring(0, 2);
            dwData["GAAUFLFD"] = ORDERNUM.Substring(2, 6);
            dwData["GAAUFPOS"] = ORDERNUM.Substring(8, 3);
            if (AUFTYP == "K")
            {
                dwData["GASA"] = "610";
            }
            if (AUFTYP == "V")
            {
                dwData["GASA"] = "713";
            }
            SResult = TMV.QGD22(dwData);
            MergeData(SResult, true);
        }

        public virtual void LOADBYCART()
        {
        }
    }
    public partial class UIGAAUF
    {
        public double GAKG1
        {
            get
            {
                return ((VGAAUF)MV).GAKG1;
            }
            set
            {
                ((VGAAUF)MV).GAKG1 = value;
            }
        }
        public double GAKG2
        {
            get
            {
                return ((VGAAUF)MV).GAKG2;
            }
            set
            {
                ((VGAAUF)MV).GAKG2 = value;
            }
        }
        public double GAKG3
        {
            get
            {
                return ((VGAAUF)MV).GAKG3;
            }
            set
            {
                ((VGAAUF)MV).GAKG3 = value;
            }
        }
        public double GAKG5
        {
            get
            {
                return ((VGAAUF)MV).GAKG5;
            }
            set
            {
                ((VGAAUF)MV).GAKG5 = value;
            }
        }
        public VGAAUF TMV
        {
            get
            {
                return (VGAAUF)MV;
            }
        }


        #region ==DATBIS===========
        public static readonly DependencyProperty DATBISProperty = DependencyProperty.Register("DATBIS",
            typeof(double), typeof(UIGAAUF),
            new FrameworkPropertyMetadata(20160618.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnDATBISChanged));
        public double DATBIS
        {
            get
            {
                return (double)GetValue(DATBISProperty);
            }
            set
            {
                SetValue(DATBISProperty, value);
            }
        }
        private static void OnDATBISChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.DATBIS = (double)e.NewValue;
            }
        }
        public virtual void OnDATBISChg(double value)
        {
            TMV.GADATBIS = value;
        }
        #endregion

        #region ==GASA===========
        public static readonly DependencyProperty GASAProperty = DependencyProperty.Register("GASA",
            typeof(string), typeof(UIGAAUF),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnGASAChanged));
        public string GASA
        {
            get
            {
                return (string)GetValue(GASAProperty);
            }
            set
            {
                SetValue(GASAProperty, value);
            }
        }
        private static void OnGASAChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.GASA = (string)e.NewValue;
            }
        }
        #endregion
        #region ==AUF===========
        public static readonly DependencyProperty AUFProperty = DependencyProperty.Register("AUF",
            typeof(string), typeof(UIGAAUF),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnAUFChanged));
        public string AUF
        {
            get
            {
                return (string)GetValue(AUFProperty);
            }
            set
            {
                SetValue(AUFProperty, value);
            }
        }
        private static void OnAUFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.AUF = (string)e.NewValue;
            }
        }
        #endregion

        #region ==LMMU===========
        public static readonly DependencyProperty LMMUProperty = DependencyProperty.Register("LMMU",
            typeof(string), typeof(UIGAAUF),
            new FrameworkPropertyMetadata("J", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnLMMUChanged));
        public string LMMU
        {
            get
            {
                return (string)GetValue(LMMUProperty);
            }
            set
            {
                SetValue(LMMUProperty, value);
            }
        }
        private static void OnLMMUChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.LMMU = (string)e.NewValue;
            }
        }
        #endregion        

        #region ==GAFARBE===========
        public static readonly DependencyProperty GAFARBEProperty = DependencyProperty.Register("GAFARBE",
            typeof(string), typeof(UIGAAUF),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnGAFARBEChanged));
        public string GAFARBE
        {
            get
            {
                return (string)GetValue(GAFARBEProperty);
            }
            set
            {
                SetValue(GAFARBEProperty, value);
                ((VGAAUF)MV).GAFARBE = value;
            }
        }
        private static void OnGAFARBEChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.GAFARBE = (string)e.NewValue;
            }
        }
        #endregion

        #region ==GSART===========
        public static readonly DependencyProperty GSARTProperty = DependencyProperty.Register("GSART",
            typeof(string), typeof(UIGAAUF),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnGSARTChanged));
        public string GSART
        {
            get
            {
                return (string)GetValue(GSARTProperty);
            }
            set
            {
                SetValue(GSARTProperty, value);
                if (IsEdit && dwGD != null)
                {
                    dwGD["GAART"] = value.Substring(0, 20);
                    dwGD["GAVAR"] = value.Substring(20, 2);
                }
            }
        }
        private static void OnGSARTChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.GSART = (string)e.NewValue;
            }
        }
        #endregion

        #region ==IsGD===========
        public static readonly DependencyProperty IsGDProperty = DependencyProperty.Register("IsGD",
            typeof(bool), typeof(UIGAAUF),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsGDChanged));
        public bool IsGD
        {
            get
            {
                return (bool)GetValue(IsGDProperty);
            }
            set
            {
                SetValue(IsGDProperty, value);
            }
        }
        private static void OnIsGDChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.IsGD = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==FTAUTOGA===========
        public static readonly DependencyProperty FTAUTOGAProperty = DependencyProperty.Register("FTAUTOGA",
            typeof(bool), typeof(UIGAAUF),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnFTAUTOGAChanged));
        public bool FTAUTOGA
        {
            get
            {
                if (MV == null) return false;
                return ((VGAAUF)MV).FTAUTOGA;
            }
            set
            {

                SetValue(FTAUTOGAProperty, value);
                if (MV == null) return;
                ((VGAAUF)MV).FTAUTOGA = value;
            }
        }
        private static void OnFTAUTOGAChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.FTAUTOGA = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==FTBX===========
        public static readonly DependencyProperty FTBXProperty = DependencyProperty.Register("FTBX",
            typeof(bool), typeof(UIGAAUF),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnFTBXChanged));
        public bool FTBX
        {
            get
            {
                if (MV == null) return false;
                return ((VGAAUF)MV).FTBX;
            }
            set
            {

                SetValue(FTBXProperty, value);
                if (MV == null) return;
                ((VGAAUF)MV).FTBX = value;
            }
        }
        private static void OnFTBXChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.FTBX = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==IsVV===========
        public static readonly DependencyProperty IsVVProperty = DependencyProperty.Register("IsVV",
            typeof(bool), typeof(UIGAAUF),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsVVChanged));
        public bool IsVV
        {
            get
            {
                return (bool)GetValue(IsVVProperty);
            }
            set
            {
                SetValue(IsVVProperty, value);
            }
        }
        private static void OnIsVVChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.IsVV = (bool)e.NewValue;
            }
        }
        #endregion


        #region ==IsFP===========
        public static readonly DependencyProperty IsFPProperty = DependencyProperty.Register("IsFP",
            typeof(bool), typeof(UIGAAUF),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsFPChanged));
        public bool IsFP
        {
            get
            {
                return (bool)GetValue(IsFPProperty);
            }
            set
            {
                SetValue(IsFPProperty, value);
            }
        }
        private static void OnIsFPChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.IsFP = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==IsKG3===========
        public static readonly DependencyProperty IsKG3Property = DependencyProperty.Register("IsKG3",
            typeof(bool), typeof(UIGAAUF),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsKG3Changed));
        public bool IsKG3
        {
            get
            {
                return (bool)GetValue(IsKG3Property);
            }
            set
            {
                SetValue(IsKG3Property, value);
            }
        }
        private static void OnIsKG3Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.IsKG3 = (bool)e.NewValue;
                src.OnIsKG3Chg((bool)e.NewValue);
            }
        }
        public virtual void OnIsKG3Chg(bool value)
        {
            if (!value)
                return;
            if (TMV == null)
                return;
            TMV.GAKG3 = TMV.GAKG1;
            TMV.GAKG5 = 0;
        }
        #endregion

        #region ==IsOrder===========
        public static readonly DependencyProperty IsOrderProperty = DependencyProperty.Register("IsOrder",
            typeof(bool), typeof(UIGAAUF),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsOrderChanged));
        public bool IsOrder
        {
            get
            {
                return (bool)GetValue(IsOrderProperty);
            }
            set
            {
                SetValue(IsOrderProperty, value);
            }
        }
        private static void OnIsOrderChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.IsOrder = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==IsChg===========
        public static readonly DependencyProperty IsChgProperty = DependencyProperty.Register("IsChg",
            typeof(bool), typeof(UIGAAUF),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsChgChanged));
        public bool IsChg
        {
            get
            {
                return (bool)GetValue(IsChgProperty);
            }
            set
            {
                SetValue(IsChgProperty, value);
            }
        }
        private static void OnIsChgChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.IsChg = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==FTMUREV===========
        public static readonly DependencyProperty FTMUREVProperty = DependencyProperty.Register("FTMUREV",
            typeof(bool), typeof(UIGAAUF),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnFTMUREVChanged));
        public bool FTMUREV
        {
            get
            {
                return (bool)GetValue(FTMUREVProperty);
            }
            set
            {
                SetValue(FTMUREVProperty, value);
            }
        }
        private static void OnFTMUREVChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.FTMUREV = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==dwGD===========
        public static readonly DependencyProperty dwGDProperty = DependencyProperty.Register("dwGD",
            typeof(DataRow), typeof(UIGAAUF),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OndwGDChanged));
        public DataRow dwGD
        {
            get
            {
                return (DataRow)GetValue(dwGDProperty);
            }
            set
            {
                SetValue(dwGDProperty, value);
            }
        }
        private static void OndwGDChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.dwGD = (DataRow)e.NewValue;
            }
        }
        #endregion

        #region ==POSTYP===========
        public static readonly DependencyProperty POSTYPProperty = DependencyProperty.Register("POSTYP",
            typeof(string), typeof(UIGAAUF),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnPOSTYPChanged));
        public string POSTYP
        {
            get
            {
                return (string)GetValue(POSTYPProperty);
            }
            set
            {
                SetValue(POSTYPProperty, value);
                if (MV == null) return;
                ((VGAAUF)MV).POSTYP = value;
            }
        }
        private static void OnPOSTYPChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.POSTYP = (string)e.NewValue;
            }
        }
        #endregion

        #region ==TOLOCK===========
        public static readonly DependencyProperty TOLOCKProperty = DependencyProperty.Register("TOLOCK",
            typeof(double), typeof(UIGAAUF),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnTOLOCKChanged));
        public double TOLOCK
        {
            get
            {
                return (double)GetValue(TOLOCKProperty);
            }
            set
            {
                SetValue(TOLOCKProperty, value);
            }
        }
        private static void OnTOLOCKChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.TOLOCK = (double)e.NewValue;
            }
        }
        #endregion


        #region ==dwRule===========
        public static readonly DependencyProperty dwRuleProperty = DependencyProperty.Register("dwRule",
        typeof(DataRow), typeof(UIGAAUF),
        new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OdwRuleChanged));

        public DataRow dwRule
        {
            get
            {
                if (MV == null) return null;
                return ((VGAAUF)MV).dwRule;
            }
            set
            {
                SetValue(dwRuleProperty, value);
                if (MV == null)
                    return;
                ((VGAAUF)MV).dwRule = value;
            }
        }
        private static void OdwRuleChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                DataRow row = (DataRow)e.NewValue;
                src.dwRule = row;
            }
        }
        #endregion

        #region ==CART===========
        public static readonly DependencyProperty CARTProperty = DependencyProperty.Register("CART",
            typeof(string), typeof(UIGAAUF),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnCARTChanged));
        public string CART
        {
            get
            {
                if (MV == null) return "";
                return ((VGAAUF)MV).CART;
            }
            set
            {
                SetValue(CARTProperty, value);
                if (MV == null)
                    return;
                ((VGAAUF)MV).CART = value;
                LOADBYCART();
            }
        }
        private static void OnCARTChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.CART = (string)e.NewValue;
            }
        }
        #endregion

        #region ==ABAUF===========
        public static readonly DependencyProperty ABAUFProperty = DependencyProperty.Register("ABAUF",
            typeof(string), typeof(UIGAAUF),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnABAUFChanged));
        public string ABAUF
        {
            get
            {
                if (MV == null) return "";
                return ((VGAAUF)MV).ABAUF;
            }
            set
            {
                SetValue(ABAUFProperty, value);
                if (MV == null)
                    return;
                ((VGAAUF)MV).ABAUF = value;

            }
        }
        private static void OnABAUFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.ABAUF = (string)e.NewValue;
            }
        }
        #endregion

        #region ==dwMU===========
        public static readonly DependencyProperty dwMUProperty = DependencyProperty.Register("dwMU",
            typeof(DataRow), typeof(UIGAAUF),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OdwMUChanged));
        public DataRow dwMU
        {
            get
            {
                return (DataRow)GetValue(dwMUProperty);
            }
            set
            {
                SetValue(dwMUProperty, value);
                if (value != null)
                {
                    ABAUF = value["ABAAUFKRS"].ToString() + value["ABAAUFLFD"].ToString() + value["ABAAUFPOS"].ToString() + value["ABPPOSTYP"].ToString();
                }
                else
                {
                    ABAUF = "";
                }
            }
        }
        private static void OdwMUChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                DataRow row = (DataRow)e.NewValue;
                src.dwMU = row;
            }
        }
        #endregion

        #region ==dwABK===========
        public static readonly DependencyProperty dwABKProperty = DependencyProperty.Register("dwABK",
            typeof(DataRow), typeof(UIGAAUF),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OdwABKChanged));
        public DataRow dwABK
        {
            get
            {
                return (DataRow)GetValue(dwABKProperty);
            }
            set
            {
                SetValue(dwABKProperty, value);
            }
        }
        private static void OdwABKChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                DataRow row = (DataRow)e.NewValue;
                src.dwABK = row;
            }
        }
        #endregion


        #region ==AUFTYP===========
        public static readonly DependencyProperty AUFTYPProperty = DependencyProperty.Register("AUFTYP",
            typeof(string), typeof(UIGAAUF),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnAUFTYPChanged));
        public string AUFTYP
        {
            get
            {
                if (MV == null) return "";
                return ((VGAAUF)MV).AUFTYP;
            }
            set
            {
                SetValue(AUFTYPProperty, value);
                if (MV == null)
                    return;
                ((VGAAUF)MV).AUFTYP = value;
            }
        }
        private static void OnAUFTYPChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.AUFTYP = (string)e.NewValue;
            }
        }
        #endregion

        #region ==ARTSTAGE===========
        public static readonly DependencyProperty ARTSTAGEProperty = DependencyProperty.Register("ARTSTAGE",
            typeof(string), typeof(UIGAAUF),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnARTSTAGEChanged));
        public string ARTSTAGE
        {
            get
            {
                if (MV == null) return "";
                return ((VGAAUF)MV).ARTSTAGE;
            }
            set
            {
                SetValue(ARTSTAGEProperty, value);
                if (MV == null)
                    return;
                ((VGAAUF)MV).ARTSTAGE = value;
            }
        }
        private static void OnARTSTAGEChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.ARTSTAGE = (string)e.NewValue;
            }
        }
        #endregion

        #region ==REQ===========
        public static readonly DependencyProperty REQProperty = DependencyProperty.Register("REQ",
            typeof(double), typeof(UIGAAUF),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnREQChanged));
        public double REQ
        {
            get
            {
                if (MV == null) return 0.0;
                return ((VGAAUF)MV).REQ;
            }
            set
            {
                SetValue(REQProperty, value);
                if (MV == null)
                    return;
                ((VGAAUF)MV).REQ = value;
            }
        }
        private static void OnREQChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.REQ = (double)e.NewValue;
            }
        }
        #endregion

        #region ==ALLQ===========
        public static readonly DependencyProperty ALLQProperty = DependencyProperty.Register("ALLQ",
            typeof(double), typeof(UIGAAUF),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnALLQChanged));
        public double ALLQ
        {
            get
            {
                if (MV == null) return 0.0;
                return ((VGAAUF)MV).ALLQ;
            }
            set
            {
                SetValue(ALLQProperty, value);
                if (MV == null)
                    return;
                ((VGAAUF)MV).ALLQ = value;
            }
        }
        private static void OnALLQChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.ALLQ = (double)e.NewValue;
            }
        }
        #endregion

        #region ==SQTY===========
        public static readonly DependencyProperty SQTYProperty = DependencyProperty.Register("SQTY",
            typeof(double), typeof(UIGAAUF),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnSQTYChanged));
        public double SQTY
        {
            get
            {
                return (double)GetValue(SQTYProperty);
            }
            set
            {
                SetValue(SQTYProperty, value);
            }
        }
        private static void OnSQTYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.SQTY = (double)e.NewValue;
            }
        }
        #endregion 

        #region ==QTYMAT===========
        public static readonly DependencyProperty QTYMATProperty = DependencyProperty.Register("QTYMAT",
            typeof(double), typeof(UIGAAUF),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnQTYMATChanged));
        public double QTYMAT
        {
            get
            {
                return (double)GetValue(QTYMATProperty);
            }
            set
            {
                SetValue(QTYMATProperty, value);
            }
        }
        private static void OnQTYMATChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.QTYMAT = (double)e.NewValue;
            }
        }
        #endregion 
        #region ==IsNewEnabled===========
        public static readonly DependencyProperty IsNewEnabledProperty = DependencyProperty.Register("IsNewEnabled",
            typeof(bool), typeof(UIGAAUF),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsNewEnabledChanged));
        public bool IsNewEnabled
        {
            get
            {
                return (bool)GetValue(IsNewEnabledProperty);
            }
            set
            {
                SetValue(IsNewEnabledProperty, value);
            }
        }
        private static void OnIsNewEnabledChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGAAUF;
            if (src != null)
            {
                src.IsNewEnabled = (bool)e.NewValue;
            }
        }
        #endregion

    }
    public partial class VGAAUF
    {

        public virtual void RESETPROD()
        {
            if (KEY.Length > 0)
                return;
            MessageInfo msg = new MessageInfo();
            msg.MSGTYPE = "RESETPROD";
            msg.Sender = this.RUNID;
            msg.ACTION = "RESETPROD";
            msg.AUFTYP = "K";
            msg.Where = app.User;
            VICC_WFEVENTS.SVWF.CheckEvents("UIMESSAGE", null, "", msg);
        }

    }
}
